﻿using System;
using System.Web.Mvc;

namespace GiveAQuiz.Web.Helpers
{
  /// <summary>
  /// This helper class provides extensions methods to the HtmlHelper 
  /// class that create commonly used buttons across the application.
  /// </summary>
  public static class ButtonHelper
  {
    /// <summary>
    /// Creates a Cancel button.
    /// </summary>
    /// <param name="html">The HtmlHelper class to extend.</param>
    /// <param name="javascriptMethod">The javascript method that will 
    /// be invoked when the button is pressed.</param>
    /// <returns>The rendered html.</returns>
    public static string CancelButton(this HtmlHelper html, string javascriptMethod)
    {
      return
          String.Format(
              "<a href='#' onclick='javascript:{0};' class='btn short ui-state-default ui-corner-all'><span class='ui-icon ui-icon-cancel'></span>Cancel</a>",
              javascriptMethod);
    }

    /// <summary>
    /// Creates an OK button.
    /// </summary>
    /// <param name="html">The HtmlHelper class to extend.</param>
    /// <param name="javascriptMethod">The javascript method that will 
    /// be invoked when the button is pressed.</param>
    /// <returns>The rendered html.</returns>
    public static string OkButton(this HtmlHelper html, string javascriptMethod)
    {
      return
          String.Format(
              "<a href='#' onclick='javascript:{0};' class='btn short btnOk ui-state-default ui-corner-all'><span class='ui-icon ui-icon-check'></span>OK</a>",
              javascriptMethod);
    }
  }
}
